package com.hjxr.sysadmin.zsj.controller;

import java.util.List;

import com.hjxr.framework.web.domain.AjaxResult;
import com.hjxr.sysadmin.uitl.poi.ExcelUtil;
import com.hjxr.sysadmin.web.controller.BaseController;
import com.hjxr.sysadmin.web.page.TableDataInfo;
import com.hjxr.sysadmin.zsj.domain.Companyinfo;
import com.hjxr.sysadmin.zsj.service.ICompanyinfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.hjxr.framework.aspectj.lang.annotation.Log;
import com.hjxr.framework.aspectj.lang.enums.BusinessType;

/**
 * 园区楼宇匹配企业信息Controller
 *
 * @author hjxr
 * @date 2021-03-15
 */
@Api("入驻服务")
@RestController
@RequestMapping("/companyinfo")
public class CompanyinfoController extends BaseController
{
    @Autowired
    private ICompanyinfoService companyinfoService;

    /**
     * 查询园区楼宇匹配企业信息列表
     */
    @ApiOperation("查询园区楼宇匹配企业信息列表")
    @GetMapping("/list")
    public TableDataInfo list(Companyinfo companyinfo)
    {
        startPage();
        List<Companyinfo> list = companyinfoService.selectCompanyinfoList(companyinfo);
        return getDataTable(list);
    }

    /**
     * 导出园区楼宇匹配企业信息列表
     */
    @ApiOperation("导出园区楼宇匹配企业信息列表")
    @Log(title = "园区楼宇匹配企业信息", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(Companyinfo companyinfo)
    {
        List<Companyinfo> list = companyinfoService.selectCompanyinfoList(companyinfo);
        ExcelUtil<Companyinfo> util = new ExcelUtil<Companyinfo>(Companyinfo.class);
        return util.exportExcel(list, "companyinfo");
    }

    /**
     * 获取园区楼宇匹配企业信息详细信息
     */
    @ApiOperation("获取园区楼宇匹配企业信息详细信息")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(companyinfoService.selectCompanyinfoById(id));
    }

    /**
     * 新增园区楼宇匹配企业信息
     */
    @ApiOperation("新增园区楼宇匹配企业信息")
    @Log(title = "园区楼宇匹配企业信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Companyinfo companyinfo)
    {
        return toAjax(companyinfoService.insertCompanyinfo(companyinfo));
    }

    /**
     * 修改园区楼宇匹配企业信息
     */
    @ApiOperation("修改园区楼宇匹配企业信息")
    @Log(title = "园区楼宇匹配企业信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Companyinfo companyinfo)
    {
        return toAjax(companyinfoService.updateCompanyinfo(companyinfo));
    }

    /**
     * 删除园区楼宇匹配企业信息
     */
    @ApiOperation("删除园区楼宇匹配企业信息")
    @Log(title = "园区楼宇匹配企业信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(companyinfoService.deleteCompanyinfoByIds(ids));
    }
}
